var express = require('express')
var path = require('path')
var cookieParser = require('cookie-parser')
var logger = require('morgan')
const cors = require('cors')

var Z_usersRouter = require('./routes/Z_user.js')
var allRouter = require('./routes/all.js')
var trafficRouter = require('./routes/traffic.js')

const ggEventRouter = require('./routes/gg_event')
const ggCheckedEventRouter = require('./routes/gg_checked_event')

var usersRouter = require('./routes/users')
var authRouter = require('./routes/auth')
var videoRouter = require('./routes/video')

var app = express()
app.use(cors())

app.use(logger('dev'))
app.use(express.json())
app.use(express.urlencoded({ extended: false }))
app.use(cookieParser())
app.use(express.static(path.join(__dirname, 'public')))

app.use('/API/V1/Z_user', Z_usersRouter)
app.use('/API/V1/all', allRouter)
app.use('/API/V1/traffic', trafficRouter)

app.use('/gg_event', ggEventRouter)
app.use('/gg_checked_event', ggCheckedEventRouter)

app.use('/auth', authRouter)
app.use('/users', usersRouter)
app.use('/video', videoRouter)

module.exports = app
